package tw.com.diary.db.util;

import java.util.Calendar;

import android.R.raw;

public class DirDateBean {

	private static final String DATE_FORMATE = "%04d/%02d/%02d";
	private static final String DATE_SAVE_FORMATE = "%04d%02d%02d";
	private static final String YYYY_MM_FORMATE = "%04d%02d";

	private int year;
	private int month;
	private int day;

	public DirDateBean() {
		final Calendar calendar = Calendar.getInstance();
		this.year = calendar.get(Calendar.YEAR);
		this.month = calendar.get(Calendar.MONTH);
		this.day = calendar.get(Calendar.DAY_OF_MONTH);
	}

	public DirDateBean(String yyyymmdd) {
		this.year = Integer.parseInt(yyyymmdd.substring(0, 4));
		this.month = Integer.parseInt(yyyymmdd.substring(4, 6)) - 1;
		this.day = Integer.parseInt(yyyymmdd.substring(6));
	}

	public String getYyyymm() {
		return String.format(YYYY_MM_FORMATE, year, month+1);
	}

	public String getShowDate() {
		return String.format(DATE_FORMATE, year, month + 1, day);
	}

	public String getDate() {
		return String.format(DATE_SAVE_FORMATE, year, month + 1, day);
	}

	public int getYear() {
		return year;
	}

	public void setYear(int year) {
		this.year = year;
	}

	public int getMonth() {
		return month;
	}

	public void setMonth(int month) {
		this.month = month;
	}

	public int getDay() {
		return day;
	}

	public void setDay(int day) {
		this.day = day;
	}

}
